#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
import MySQLdb

class getconfig():
    def __init__(self,cursor):
        self.cursor=cursor
    #页面转化    
    def get_page_config(self):
        self.cursor.execute("select cid,sid,pages from nas_conversion_page where cid is not null and sid is not null")
        result=cursor.fetchall()
        return result
    #事件转化
    def get_event_config(self):
        self.cursor.execute("select cid,sid,eid,times from nas_conversion_event where cid is not null and sid is not null")
        result=cursor.fetchall()
        return result
    #时长转化
    def get_time_config(self):
        self.cursor.execute("select cid,sid,time from nas_conversion_time where cid is not null and sid is not null and ison=1")
        result=cursor.fetchall()
        return result
    #页数转化
    def get_pagenum_config(self):
        self.cursor.execute("select cid,sid,pagenum from nas_conversion_pagenum where cid is not null and sid is not null and ison=1")
        result=cursor.fetchall()
        return result
    
if __name__ == '__main__':
    host=sys.argv[1]
    port=sys.argv[2]
    user=sys.argv[3]
    password=sys.argv[4]
    db=sys.argv[5]
    method=sys.argv[6]
    conn=MySQLdb.connect(host,user,password,db)
    cursor=conn.cursor()
    gc=getconfig(cursor)
    result=getattr(gc,method)()
    for line in result:
        print "\001".join(map(str,line))
    